package com.leyou.item.api;

import com.leyou.item.entity.Sku;
import com.leyou.item.entity.Spu;
import com.leyou.item.entity.SpuDetail;
import com.leyou.item.vo.PageResult;
import com.leyou.item.vo.SpuVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author linzx
 * @date 2020/3/26
 */
@RequestMapping()
public interface GoodsApi {
    /**
     * 根据id查询SpuDetail
     * @param spuId
     * @return
     */
    @GetMapping("spu/detail/{spuId}")
    SpuDetail findSpuDetailById(@PathVariable("spuId")Long spuId);

    /**
     * 根据spuId查询sku
     * @param spuId
     * @return
     */
    @GetMapping("sku/list")
    List<Sku> findSkuBySpuId(@RequestParam("id") Long spuId) ;

    /**
     * 分页查询skuvo
     * @param key
     * @param saleable
     * @param page
     * @param rows
     * @return
     */
    @GetMapping("spu/page")
    PageResult<SpuVO> querySpuPage(
            @RequestParam(value = "key",required = false) String key,
            @RequestParam(value = "saleable",required = false) Boolean saleable,
            @RequestParam(value = "page",defaultValue = "1") Integer page,
            @RequestParam(value = "rows",defaultValue = "5") Integer rows
    );

    /**
     * 根据id查询spu
     * @param id
     * @return
     */
    @GetMapping("spu/{id}")
    Spu querySpuById(@PathVariable("id")Long id);

    /**
     * 根据ids查询spu
     * @param ids
     * @return
     */
    @GetMapping("spu/list")
   List<SpuVO> querySpuById(@RequestParam("ids")List<Long> ids) ;

//    @PostMapping("stock/decrease")
//    void decreaseStock(@RequestBody List<CartDTO> cartDTOS);
}
